home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / newlooklib.lha / newlook / createborder.c < prev    next >
C/C++ Source or Header  |  1993-10-24  |  2KB  |  70 lines

  1. /*
  2.  *  CREATEBORDER.C
  3.  */
  4.  
  5. #include "newlook.h"
  6.  
  7. struct Border *CreateBorder(x,y,w,h,pn)
  8. SHORT x,y,w,h;
  9. BOOL pn; /* FALSE=positive, TRUE=negative */
  10. {
  11.   struct Border *tl, *br;  /* TopLeft, BottomRight */
  12.   SHORT *xy;
  13.  
  14.   ULONG UserHandle= SetNewLookHandle(PRIVATE_HANDLE);
  15.  
  16.   if(tl= (struct Border *)SmartAllocate(BORDERSIZE))
  17.   {
  18.     if(br= (struct Border *)SmartAllocate(BORDERSIZE))
  19.     {
  20.       if(xy= (SHORT *)SmartAllocate(2*BORDERXYSIZE))
  21.       {
  22.         --w;
  23.         --h;
  24.  
  25.         /* shining edges */
  26.         xy[0]= w-1;   xy[1]= 0;       /*  ++++++++++++  */
  27.         xy[2]= 0;     xy[3]= 0;       /*  ++            */
  28.         xy[4]= 0;     xy[5]= h;       /*  ++            */
  29.         xy[6]= 1;     xy[7]= h-1;     /*  ++            */
  30.         xy[8]= 1;     xy[9]= 1;       /*  +             */
  31.  
  32.         /* shadow edges */
  33.         xy[10]= 1;    xy[11]= h;      /*              + */
  34.         xy[12]= w;    xy[13]= h;      /*             ++ */
  35.         xy[14]= w;    xy[15]= 0;      /*             ++ */
  36.         xy[16]= w-1;  xy[17]= 1;      /*             ++ */
  37.         xy[18]= w-1;  xy[19]= h-1;    /*   ++++++++++++ */
  38.  
  39.         /* top, left (shining) border */
  40.         tl->LeftEdge   = x;
  41.         tl->TopEdge    = y;
  42.         tl->FrontPen   = pn ? 1:2;
  43.         tl->BackPen    = 0;
  44.         tl->DrawMode   = JAM1;
  45.         tl->Count      = 5;
  46.         tl->XY         = &xy[0];
  47.         tl->NextBorder = br;
  48.  
  49.         /* bottom, right (shadow) border */
  50.         br->LeftEdge   = x;
  51.         br->TopEdge    = y;
  52.         br->FrontPen   = pn ? 2:1;
  53.         br->BackPen    = 0;
  54.         br->DrawMode   = JAM1;
  55.         br->Count      = 5;
  56.         br->XY         = &xy[10];
  57.         br->NextBorder = (struct Border *)NULL;
  58.  
  59.         MakePrivateHandlePublic(UserHandle);
  60.         return(tl);
  61.       }
  62.     }
  63.   }
  64.   if(UserHandle != PRIVATE_HANDLE)
  65.   { SmartFreeAll(PRIVATE_HANDLE);
  66.     (void)SetNewLookHandle(UserHandle);
  67.   }
  68.   return (struct Border *)NULL;
  69. }
  70.